package com.example.frame_animation;

import android.graphics.drawable.AnimationDrawable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageView;

public class MainActivity extends AppCompatActivity {
    private static final String TAG = "MainActivity";
    private ImageView iv_frame;
    private Button btnStrat;
    private AnimationDrawable animationDrawable;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        iv_frame = findViewById(R.id.iv_frame);
        btnStrat = findViewById(R.id.bgt_strat);
        /*animationDrawable = (AnimationDrawable) iv_frame.getBackground();*/

        btnStrat.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.e(TAG,"onClick"+v.getId());
                /*//Frame动画调用
                if (animationDrawable.isRunning()){
                    animationDrawable.stop();
                }

                animationDrawable.start();*/

                Animation alpha = AnimationUtils.loadAnimation(MainActivity.this,R.anim.translate_anim);
                iv_frame.startAnimation(alpha);

            }
        });

    }
}
